package com.easylinkin.linkappapi.afterloan.controller;
import com.easylinkin.linkappapi.afterloan.entity.AfterloanRiskType;
import com.easylinkin.linkappapi.afterloan.service.AfterloanEnterpriseinfoService;
import com.easylinkin.linkappapi.afterloan.service.AfterloanRiskTypeService;
import com.easylinkin.linkappapi.common.model.RequestModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;

/**
 * @program: linkapp-group
 * @description: 风险分类
 * @author: chenkaixuan
 * @create: 2021-05-22 11:39
 */
@RestController
@RequestMapping("/afterloan/managmonitor")
public class AfterloanRiskTypeController {

    @Autowired
    AfterloanRiskTypeService service;
    @Autowired
    AfterloanEnterpriseinfoService afterloanEnterpriseinfoService;

    @PostMapping("getRiskAll")
    public RestMessage getRiskAll(@RequestBody RequestModel<AfterloanRiskType> requestModel){
        Assert.notNull(requestModel.getCustomQueryParams(), "customQueryParams 不能为空");
        Assert.notNull(requestModel.getPage(), "page 不能为空");
        return RestBuilders.successBuilder().data(afterloanEnterpriseinfoService.getESAfterloanPageAll(requestModel.getPage(),requestModel.getCustomQueryParams())).build();
    }

    @PostMapping("getRiskDetails")
    public RestMessage getRiskDetails(@RequestBody AfterloanRiskType afterloanRiskType){
        return RestBuilders.successBuilder().data(afterloanEnterpriseinfoService.getEsDateByTypeAndEnterpriseIdDetails(afterloanRiskType)).build();
    }

//    /***
//     * 查询获取列表信息
//     * @return
//     */
//    @PostMapping("getAll")
//    public RestMessage getAll(@RequestBody AfterloanRiskType afterloanRiskType){
//        return RestBuilders.successBuilder().data(service.getAll(afterloanRiskType)).build();
//    }
}
